home *** CD-ROM | disk | FTP | other *** search
/ Aminet 30 / Aminet 30 (1999)(Schatztruhe)[!][Apr 1999].iso / Aminet / dev / misc / fcxref.lha / FCXRef / Src / head.l < prev    next >
Text File  |  1999-02-08  |  1KB  |  70 lines

  1. %{
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <ctype.h>
  5.  
  6. extern int AddFunc(char *file, char *func,int linenum);
  7. extern int opt_struct;
  8.  
  9. char *actfile;
  10. int lineno;
  11. char struname[1024];
  12. int struline;
  13.  
  14. %}
  15.  
  16. %x      xdefine
  17. %x        xstruct
  18. %x        ins
  19.  
  20. %%
  21.  
  22. [" "\t]*"#define"[" "\t]+    { BEGIN(xdefine); }
  23. [" "\t]*"struct"[" "\t]+    {
  24.                             if(opt_struct!=0) BEGIN(xstruct);
  25.                             }
  26.  
  27. <xdefine>[a-zA-Z0-9_]+    {
  28.                         int l;
  29.                         l=strlen(yytext)-1;
  30.                         if(yytext[l]!='H'&&yytext[l-1]!='_') {
  31.                             AddFunc(actfile,yytext,lineno);
  32.                             }
  33.                         BEGIN(INITIAL);
  34.                         }
  35. <xstruct>[a-zA-Z0-9_]+    {
  36.                         struline=lineno;
  37.                         if(strlen(yytext)<1024) strcpy(struname,yytext);
  38.                         else struname[0]='\0';
  39.                         BEGIN(ins);
  40.                         }
  41. <ins>[^" "\t\n{]        {
  42.                         BEGIN(INITIAL);
  43.                         }
  44. <ins>[" "\t]*
  45. <ins>\n                    { lineno++; }
  46. <ins>"{"                {
  47.                         if(struname[0]!='\0') {
  48.                             AddFunc(actfile,struname,struline);
  49.                         }
  50.                         BEGIN(INITIAL);
  51.                         }
  52. <xstruct>"\n"            { ++lineno; BEGIN(INITIAL); }
  53. <xstruct>.                { BEGIN(INITIAL); }
  54.  
  55. "\n"                    { ++lineno; }
  56. .
  57.  
  58. %%
  59.  
  60. void scanhead(char *file) {
  61.     FILE *f;
  62.  
  63.     actfile=file;
  64.     lineno=1;
  65.     if(NULL==(yyin=f=fopen(file,"rb"))) return;
  66.     yylex();
  67.     fclose(f);
  68. }
  69.  
  70.